/**
 * 
 */
package nc.tb.pub.ui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.Icon;

/**
 * @author xuzx
 *
 */
public class ClosableIcon implements Icon {

	protected int x_pos;

	protected int y_pos;

	protected int width;

	protected int height;

	public ClosableIcon() {
		width = 9;
		height = 9;
	}

	// @Override
	public void paintIcon(Component c, Graphics g, int x, int y) {
		this.x_pos = x;
		this.y_pos = y;
		Color col = g.getColor();
		g.setColor(Color.WHITE);
		int y_p = y;
		x += 2;
		g.drawLine(x, y_p, x + 6, y_p + 6);
		g.drawLine(x, y_p + 1, x + 5, y_p + 6);
		g.drawLine(x + 1, y_p, x + 6, y_p + 5);
		g.drawLine(x + 6, y_p, x, y_p + 6);
		g.drawLine(x + 6, y_p + 1, x + 1, y_p + 6);
		g.drawLine(x + 5, y_p, x, y_p + 5);
		g.setColor(col);
	}

	// @Override
	public int getIconWidth() {
		return width;
	}

	// @Override
	public int getIconHeight() {
		return height;
	}

	public Rectangle getBounds() {
		return new Rectangle(x_pos, y_pos, width, height);
	}

}
